package com.example;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.concurrent.TimeUnit;

/**
 * @Classname Application
 * @Description TODO
 * @Date 2022/3/22 16:56
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@SpringBootApplication
@EnableDiscoveryClient
@Slf4j
public class Application {

    /**
     *  nacos :  http://192.168.14.1:8848/nacos/index.html
     * @param args
     */
    public static void main(String[] args) throws Exception {
        ConfigurableApplicationContext applicationContext=SpringApplication.run(Application.class,args);

//        while (true) {
//            //当动态配置刷新时，会更新到 Enviroment中，因此这里每隔一秒中从Enviroment中获取配置
//            String userName = applicationContext.getEnvironment().getProperty("user.name");
//            String userAge = applicationContext.getEnvironment().getProperty("user.age");
//            log.info("配置信息，名称：{}，年龄：{}", userName, userAge);
//            TimeUnit.SECONDS.sleep(1);
//        }
    }


}
